<template>
	<div class="allcontainer" v-loading="loading">
		<div class="h2">活动签到记录</div>
		<div class="bg-white">
			<div class="table">
				<el-table ref="singleTable" :data="data" style="width: 100%">
					<!-- <el-table-column prop="AddUserName" label="姓名" min-width="100" fixed="left"></el-table-column> -->
					<el-table-column prop="AddUserNo" label="是否签到" min-width="100" align="center">
						<template slot-scope="scope">
							<a-tag color="green" v-if="scope.row.IsSign==true"> 已签到 </a-tag>
							<a-tag color="pink" v-else> 未签到 </a-tag>
						</template>
					</el-table-column>
					<el-table-column prop="SignTime" label="签到时间" min-width="120" align="center"></el-table-column>
					<el-table-column prop="TypeName" label="类型" min-width="120" align="center"></el-table-column>
					<!-- <el-table-column prop="IsManager" label="职责" min-width="100">
					<template slot-scope="scope">
						<a-tag color="pink" v-if="scope.row.IsManager==true"> 管理员 </a-tag>
						<a-tag color="green" v-else> 成员 </a-tag> 
					</template>
				</el-table-column> -->
					<el-table-column prop="AddTime" label="时间" min-width="100" align="center">
						<template slot-scope="scope">
							<div>始：{{ scope.row.StartTime }}</div>
							<div>终：{{ scope.row.EndTime }}</div>
						</template>
					</el-table-column>
					<!-- <el-table-column prop="IsEnable" label="操作" min-width="100" fixed="right">
					<template slot-scope="scope">
						<i title="查看" v-if="!scope.row.IsManager" class="iconfont icon-chakan" style="color: #1890FF;" @click="look(scope.row)"></i>
						<i title="修改" v-if="ChairmanNo == UserInfo.UserNo" class="iconfont icon-editor1" style="color: #1890FF;"
						 @click="detail(scope.row)"></i>
						 <i title="二维码"  class="iconfont icon-two-dimensional-code" style="color: green;"
						  @click="codeimg(scope.row)"></i>
						 <i title="删除" v-if="!scope.row.IsManager" class="iconfont icon-delete1" style="color: red;" @click="deletemember(scope.row)"></i>
					</template>
				</el-table-column> -->
				</el-table>
				<!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage"
			 :page-sizes="pagination.pageSizeOptions" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
			 :total="pagination.total"></el-pagination> -->
			</div>
		</div>
		<add :text="text" :ID="ID" v-show="addIf" @closeFun="closeFun"></add>
		<imgcode :codeID="codeID" :time="time" v-show="codeIf" @closeFun="closeFun"></imgcode>
		<detail :text="detailtext" v-show="detailIf" @closeFun="closeFun"></detail>
	</div>
</template>

<script>
	import Func from '@/utils/func';
	import Cache from '@/utils/cache'
	import {
		UserDoGetSignList

	} from '@/api/follow';
	import add from './AddActivitySign'
	import imgcode from './QRcode'
	import detail from './UserActivitySignDetail'
	const data = [];
	export default {
		components: {
			add,
			detail,
			imgcode
		},
		data() {
			return {
				data,
				form: this.$form.createForm(this, {
					name: 'advanced_search'
				}),
				pagination: {
					currentPage: 1,
					pageSize: this.global.pageSize,
					pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
					showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
				},
				addIf: false,
				text: {},
				detailtext: {},
				codeID: '',
				visible: false,
				confirmLoading: false,
				itemId: '',
				departmentList: [],
				worklist: [],
				loading: false,
				values: {},
				pages: {
					pageIndex: 1,
					pageSize: 20
				},
				tableHeight: parseFloat(window.innerHeight - 160),
				TypeIDList: [],
				DepartCodeList: [],
				ProjectIDList: [],
				ishaveid: true,
				selectList: {},
				showModal: false,
				UserInfo: Cache.get('myInfo'),
				ChairmanNo: this.$route.query.ChairmanNo,
				linktype: 1,
				ID: this.$route.query.ID,
				visible: false,
				deletelist: {},
				time: '',
				codeIf: false,
				detailIf: false
			};
		},
		computed: {},
		created() {
			this.getList();
			// this.getOtherList()
		},
		mounted() {},
		methods: {
			codeimg(text) {
				// let data={}
				// data.id=text.ID
				// let res= await GetUserActivitySignQRImage(data)
				this.time = new Date()
				this.codeID = text.ID
				this.codeIf = true
			},
			handleCancel(e) {
				this.visible = false
				this.getList()
			},
			deletemember(text) {
				// this.visible = true
				// this.deletelist = text
				let that = this
				this.$confirm({
					title: '提示',
					content: `您确定删除此条记录吗？`,
					okText: '确认',
					cancelText: '取消',
					async onOk() {
						let data = {}
						data.id = text.ID
						let res = await DeleteUserActivitySign(data);
						if (res.data.code == 0) {
							that.getList()
							that.$message.success(res.data.msg)
						} else {
							that.$message.error(res.data.msg)
						}
					}
				})
			},
			detail(text) {
				this.text = text
				this.time = new Date()
				this.addIf = true
			},
			look(text) {
				this.detailtext = text
				this.time = new Date()
				this.detailIf = true
			},
			handleChange(val) {
				this.currentRow = val;
				if (val.ID) {
					this.ishaveid = false
					this.selectList = val
				} else {
					this.ishaveid = true
				}
			},
			handleSearch(e) {
				e.preventDefault();
				this.form.validateFields((error, values) => {
					this.pagination.currentPage = 1;
					this.values = values;
					this.getList();
				});
			},
			handleReset() {
				this.form.resetFields();
				this.values = {};
				this.getList();
			},
			handleSizeChange(val) {
				this.pagination.pageSize = val;
				this.getList();
			},
			handleCurrentChange(val) {
				this.pagination.currentPage = val;
				this.getList();
			},
			async getList() {
				this.loading = true;
				let data = {};
				if (this.values) {
					data = this.values;
				}
				data.activityID = this.$route.query.ID
				data.type = 1
				data.pageIndex = this.pagination.currentPage;
				data.pageSize = this.pagination.pageSize;
				let res = await UserDoGetSignList(data);
				this.loading = false;
				this.data = res.data.data;
				// const pagination = { ...this.pagination
				// };
				// pagination.total = res.data.pageInfo.TotalItemCount;
				// this.pagination = pagination;
			},
			// async getOtherList() {
			// 	let res = await UserUpdateActivity()
			// 	this.TypeIDList = res.data.data
			// },
			addList() {
				this.text = {};
				this.addIf = !this.addIf;
			},
			modifyList(text) {
				text = Object.assign(text, {
					time: new Date()
				});
				this.addIf = !this.addIf;
				this.text = text;
			},
			closeFun(index) {
				this.showModal = false
				this.addIf = false
				this.detailIf = false
				this.codeIf = false
				this.getList()
			},
		}
	};
</script>
